# Contributor: Will Sinatra <wpsinatra@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libdrm
pkgver=2.4.119
pkgrel=0
pkgdesc="Userspace interface to kernel DRM services"
url="https://gitlab.freedesktop.org/mesa/drm"
arch="all"
# Requires a computer with gfx, no X running, build user in 'video' group..
options="!check"
license="MIT"
depends_dev="linux-headers"
makedepends="$depends_dev meson eudev-dev libpciaccess-dev xmlto"
checkdepends="cunit-dev bash"
subpackages="$pkgname-dev $pkgname-tests"
source="https://gitlab.freedesktop.org/mesa/drm/-/archive/libdrm-$pkgver/drm-libdrm-$pkgver.tar.gz"
builddir="$srcdir/drm-libdrm-$pkgver"

build() {
	CFLAGS="$CFLAGS -O2" \
	CPPFLAGS="$CPPFLAGS -O2" \
	CXXFLAGS="$CXXFLAGS -O2" \
	abuild-meson \
		-Db_lto=true \
		-Dfreedreno=enabled \
		-Dintel=enabled \
		-Dtegra=enabled \
		-Domap=enabled \
		-Dexynos=enabled \
		-Dvc4=enabled \
		-Detnaviv=enabled \
		-Dudev=true \
		-Dinstall-test-programs=true \
		-Dtests=true \
		. output
	meson compile -C output
}

check() {
	meson test --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

tests() {
	amove usr/bin
}

sha512sums="
620398e6e2d44c61f9ab90036d03a1f236213aa865623e96cae08960fcd43a4802a2c55cd9fd1a16c5a66f48373d30c6e70899895bdb3965208b28eefce29626  drm-libdrm-2.4.119.tar.gz
"
